﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FAP.DataAccess.BLL;

namespace FAP.DataAccess
{
    public class WebsiteDAO
    {
        private static FAPDataContext m_context = new FAPDataContext();

        public static website GetWebSite(string tensite)
        {
            m_context = new FAPDataContext();
            website obj_tk = new website();
            obj_tk = (from tk in m_context.websites
                      where tk.link == tensite
                      select tk).Single();
            return obj_tk;
        }

        public static List<website> GetWebSite()
        {
            m_context = new FAPDataContext();
            var obj_tk = (from tk in m_context.websites
                      select tk);
            return obj_tk.ToList();
        }

        public static void Update(website web)
        {
            m_context = new FAPDataContext();
            var w =  m_context.websites.First(p=> p.id == web.id);
            w.link = web.link;
            w.trangthai = web.trangthai;
            m_context.SubmitChanges();

        }
    }
}
